package com.rjwh.dingdong.client.activity.more;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;

import com.rjwh.dingdong.client.R;
import com.rjwh.dingdong.client.activity.BaseActivity;
import com.rjwh.dingdong.client.application.MyApplication;
import com.rjwh.dingdong.client.constant.LocalConstant;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author Kay
 * @ClassName MoreAccountSecurityActivity
 * @Description
 * @date 2016-10-19
 * @history 2016-10-19 author: description:
 */
public class MoreAccountSecurityActivity extends BaseActivity {
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.more_account_security_change_password_icon_tv)
    TextView moreAccountSecurityChangePasswordIconTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.more_account_security_layout);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        String haspwd = MyApplication.spUtil.getStrPreferenceByParamName(MyApplication.getInstance(), LocalConstant.SP_USER_HASPWD);
        initToolbarHelper();
        if (haspwd.equals("1")) {
            moreAccountSecurityChangePasswordIconTv.setText(getResources().getString(R.string.more_account_security_change_password));
        }else {
            moreAccountSecurityChangePasswordIconTv.setText(getResources().getString(R.string.more_account_security_set_password));
        }
    }

    private void initToolbarHelper() {
        this.setSupportActionBar(this.toolbar);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(getResources().getString(R.string.more_setting_account_security));
        }
        getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    @OnClick(R.id.more_account_security_change_password_root)
    public void onClick() {
        startActivity(new Intent(this, MoreChangePasswordActivity.class));
    }
}
